package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.ExportPartnerReqDto;
import com.yixun.qfbao.apidto.ExportPartnerResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.ExportPartnerReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/25
 * @Author sangtao
 * @Computer Administrator
 */
@Service("exportPartnerHander")
public class ExportPartnerHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(ExportPartnerHander.class);
    @Autowired
    private PersonnelService personnelService;

    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        ExportPartnerReqVo req = (ExportPartnerReqVo)reqDto;
        ExportPartnerReqDto exportPartnerReqDto = req.getParams();
        BaseResponseDTO<ExportPartnerResDto> res = new BaseResponseDTO<ExportPartnerResDto>();
        ExportPartnerResDto resDto = new ExportPartnerResDto();
        try {
            resDto = personnelService.exportPartner(exportPartnerReqDto);
        } catch (Exception e) {
            logger.error("ExportPartnerHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("导出文件失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
